let hello = "Hello";
({ hello } = { hello: "hello" });
console.log(hello);

let a = Symbol('a');
let b = Symbol('a');

console.log(a == b);
console.log(a === b);
console.log(a, b);


let field = Symbol('name');

// let obj = {
//     field:'zhangsan'
// }

// let obj = {
//     'field': 'zhangsan'
// }

// let obj = {
//     field
// }
// let obj = {
//     field: field
// }

let obj = {};

// obj.field = "zhangsan";
// obj['field'] = 'zhangsan';
obj[field] = 'zhangsan';

// obj.field = obj['field']
console.log(obj.field); //      undefined
console.log(obj['field']); //   undefined
console.log(obj.name); //       undefined
console.log(obj['name']); //    undefined

console.log(obj[field]);

// let prop = 'name';
// obj[prop] = obj['name'] = obj.name


let obj2 = {
    name: 'zs',
    age: 20
}
obj2[field] = 'symbol';

// for (let key in obj2) {
//     console.log(key);
//     // console.log(obj2[key]);
// }

// for..of 不能遍历对象, 只能遍历数组/字符串
// for (let key of Object.keys(obj2)) {
//     console.log(key);
// }

console.log(obj2);
// console.log(Object.keys(obj2)); // [ 'name', 'age' ]
// console.log(Object.getOwnPropertyNames(obj2)); //  [ 'name', 'age' ]
console.log(Object.getOwnPropertySymbols(obj2)); // [ Symbol(name) ]